package com.zky.gulimall.member.web;

import com.alibaba.fastjson.JSON;
import com.zky.common.utils.R;
import com.zky.gulimall.member.feign.OrderFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description 会员相关
 * @Author 张开源
 * @Date 2022/12/23 10:39
 * @Version 1.0
 **/
@Controller
@Slf4j
public class MemberWebController {
    @Autowired
    private OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, Model model) {
        //此处可用于支付完更新订单状态，但是必须要验证签名，这么做不推荐
        Map<String, Object> query = new HashMap<>();
        query.put("page", String.valueOf(pageNum));
        R r = orderFeignService.listWithItem(query);
        if(r.isSuccess()){
            log.warn("memberOrderPage result:{}", JSON.toJSONString(r.get("page")));
        }
        model.addAttribute("orders", r);
        return "orderList";
    }
}
